<template>
	<div>
		<section style="height: 3rem;"></section>
		
		<section style="width: 100%;justify-content: center;align-items: center;display: flex;">
			<section style="width: 60%;display: flex;flex-direction: column;">
				<el-select v-model="factoryId" filterable placeholder="请选择" style="margin-top: 2rem;">
				    <el-option
				      v-for="item in options"
				      :key="item.id"
				      :label="item.factoryname"
				      :value="item.id">
				    </el-option>
			  	</el-select>
	  	
			  	<el-input style="margin-top: 2rem;" v-model="userName" placeholder="请输入用户名"></el-input>
			 
			  	<el-input  style="margin-top: 2rem;"  v-model="passwordold" placeholder="请输入旧密码"  class="psd" type="text" ></el-input>
			  	
			  	<el-input  style="margin-top: 2rem;"  v-model="passwordnew" placeholder="请输入新密码"  class="psd" type="text" ></el-input>			  	
			  	  
			  	
			  	<!--<el-input style="margin-top: 2rem;" v-model="confirmPassword" placeholder="请再次输入用户密码"></el-input>-->
			  	
			  	<section style="margin-top: 2rem;display: flex;justify-content: center;justify-content:space-between;align-items: center;flex-direction: row;" >
			  		<el-button type="info" @click="gotoAddress('factoryList')">返回</el-button>
					<el-button type="primary" @click="ChangePassword()">确定</el-button>
				</section>
			  	 
			</section>
			
			
		</section>
	</div>
</template>
     



<script>
	
	import TopNav from '@/components/nav/topNav.vue'
     
     export default{
     	components:{
     		TopNav,
     	},
     	data(){
     		return {
     			options:[],
     			factoryId:'',
     			userName:'',
     			passwordold:'',
     			passwordnew:'',
     			psd:'',
     			ifDisplay:false
     		}
     	},
     	mounted(){
     		this.getBindlist()
     	},
     	methods:{
     		gotoAddress(path){
     			var self = this
     			setTimeout(function(){
     				self.$router.push(path)
     			},200)
     		},
     		getBindlist(){
    		let that=this
    		that.axios.get('/factory/getFactoryListX').then(function(response){
		 		that.options=response.data.data
//		 		that.gotoAddress({path:'index2'})
		 	}).catch(function(error){
		 		console.info(error)
		 	})
		},
     	    ChangePassword(){
     	    	let that = this
     	    	that.axios.post('/factoryUser/ChangeFactoryUserPassword',{
     	    		'factoryUsername':that.userName,
				     'passwordold':that.passwordold,
				     'passwordnew':that.passwordnew,
				     'factoryId':that.factoryId
     	    }).then(function(response){//？？？？？？？？
		 		if(response.data.code==0){
		 			if(response.data.data.state=="ok")
		 			{
					console.info(response.data)
					that.$message({type: 'success',message: '修改成功!',duration:1500})
					//that.$router.push({path: 'factoryList'})
					//that.$router.replace("factoryList")
					//that.$router.replace('/refresh')
					//location.reload()//刷新
					// 先进入一个空路由
                    //that.$router.replace({path: '/_empty',})
                    //then replace your route (with same component)
                    //that.$router.replace({path: 'factoryList'})
					that.$router.replace("factoryList")
                    //this.$router.push({path: 'factoryList'})
                    }else{
		 		     	//that.$router.go(-1)
					  that.$message({type: 'info',message: '修改失败,原因:'+response.data.data.msg,duration:1500});
		 		     }
				}else{
					that.$message({type: 'info',message: '修改失败,原因'+response.data.msg,duration:1500});
				}
		 	}).catch(function(error){
		 		console.info(error)
		 		that.$message({type: 'info',message: '修改失败'+error.Message,duration:1500});
		 		that.$router.replace("factoryList")
		 	})
		},
		clearPassword:function(){
			this.psd='';
		}
     	}
     }
</script>

<style>
	.aboutpass{
      margin-top: 2rem;;
     }
      .aboutpass .psd{
      width:99.9%; 
      }
</style>